<?php

namespace two;
require_once __DIR__ . '/../vendor/autoload.php';
use PhpAmqpLib\Connection\AMQPStreamConnection;
use PhpAmqpLib\Message\AMQPMessage;

/**
 * 死信生产者代码
 */
class Producer
{
    // 普通交换机的名称
    public static $normalExchange = 'normal_exchange';
    public function __construct()
    {
        self::Producer();
    }

    public static function Producer()
    {
        $connection = new AMQPStreamConnection('localhost', 5672, 'guest', 'guest');
        $channel = $connection->channel();

        for ($i = 1; $i < 11; $i++) {
            $msg = 'info' . $i;
            $channel->basic_publish($msg, self::$normalExchange, 'PHP-Key');
        }
    }
}

new Producer();